package com.yu.demo.controller;

import com.yu.demo.util.WebCache;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class Test {

    @RequestMapping(value = "/mapFirst" , method= RequestMethod.GET)
    public String mapFirst(){
        try {

        }catch (Exception e){
            e.getMessage();
            e.getStackTrace();
        }
        for(int i=0;i<5000;i++){
            Map<String,String> testMap = mapTest("mapTest",String.valueOf(i));
        }
        return "mapFirst";
    }

    public static void main(String[] args) {
        String test = "https://oateh.tcl.com/ekp/km/abc";
        System.out.println(test.indexOf("ekp/login.jsp"));
    }


    @RequestMapping(value = "/mapSecond" , method= RequestMethod.GET)
    public String mapSecond(){
        Map<String,String> testMap = new HashMap<String,String>();
        for(int i=5000;i<10000;i++){
            testMap = mapTest("mapTest",String.valueOf(i));
        }
        return "mapSecond";
    }

    public HashMap<String,String> mapTest(String temp,String sort){
        HashMap<String,String> map = new HashMap<String,String>();
        if(map.size()>0){
            return map;
        }
        map.put("test1","test1");
        if(!StringUtils.isEmpty(temp)){
            map.put("temp",temp);
        }
        List<String> testList = new ArrayList<String>();
        testList.add(sort);
        WebCache.servicePath.put(sort,testList);
        return map;
    }



}
